#include "ComboControllerProperty.h"

const StringHash ComboControllerProperty::COMBO_CONTROLLER_PROPERTY_ID = StringHash("comboControllerProp");

ComboControllerProperty::ComboControllerProperty(const ObjectId& objectId, char key1, char key2, real maxTime)
	:ObjectProperty(COMBO_CONTROLLER_PROPERTY_ID, objectId)
	,m_key1(key1)
	,m_key2(key2)
	,m_inProgress(false)
	,m_completed(false)
	,m_maxTime(maxTime)
	,m_executionTimer(0.0f)
{
}

ComboControllerProperty::~ComboControllerProperty()
{
}

char ComboControllerProperty::getKey1() const 
{
	return m_key1;
}

char ComboControllerProperty::getKey2() const
{
	return m_key2;
}

bool ComboControllerProperty::inProgress() const
{
	return m_inProgress;
}

bool ComboControllerProperty::isCompleted() const
{
	return m_completed;
}

void ComboControllerProperty::startCombo()
{
	m_inProgress = true;
	resetTimer();
}

void ComboControllerProperty::stopCombo()
{
	m_inProgress = false;
	m_completed = false;

	resetTimer();
}

void ComboControllerProperty::completeCombo()
{
	m_completed = true;
}

void ComboControllerProperty::updateTimer(const real elapsedTime)
{
	m_executionTimer += elapsedTime;

	if (m_executionTimer > m_maxTime)
	{
		stopCombo();
	}
}

void ComboControllerProperty::resetTimer()
{
	m_executionTimer = 0.0f;
}